package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.Course;
import com.hl.sfzy.mapper.CourseMapper;
import com.hl.sfzy.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseMapper courseMapper;
    @Override
    public int removeByPrimaryKey(Long id) {
        return courseMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int add(Course course) {
        return courseMapper.insert(course);
    }

    @Override
    public Course findByPrimaryKey(Long id) {
        return courseMapper.selectByPrimaryKey(id);
    }

    @Override
    public int editByPrimaryKey(Course course) {
        return courseMapper.updateByPrimaryKey(course);
    }

    @Override
    public int removeBatch(List<Long> ids) {
        return courseMapper.deleteBatch(ids);
    }

    @Override
    public List<Course> find(int pageNum, int pageSize) {
        return courseMapper.select(pageNum,pageSize);
    }

    @Override
    public PageInfo<Course> findByPage(int pageNum, int pageSize, Course course) {
        PageHelper.startPage(pageNum,pageSize);
        List<Course> list = courseMapper.selectByPage(pageNum,pageSize,course);
        PageInfo<Course> pageInfo = new PageInfo<>(list);
        return pageInfo;

    }

    @Override
    public List<Course> findCourseConsultants(Long id) {
        return courseMapper.selectCourseConsultants(id);
    }
    @Override
    public List<Course> selectByConsultantId(Long id) {
        return courseMapper.selectByConsultantId(id);
    }
}
